home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_oth / forchek1 / forchek.h < prev    next >
C/C++ Source or Header  |  1991-11-05  |  10KB  |  325 lines

  1. /* forchek.h:
  2.  
  3.  Common definitions for Fortran Program Checker
  4.  
  5.     Copyright (C) 1991 by Robert K. Moniot.
  6.     This program is free software.  Permission is granted to
  7.     modify it and/or redistribute it, retaining this notice.
  8.     No guarantees accompany this software.
  9.  
  10. */
  11.  
  12. #define VERSION_NUMBER  "FORCHEK Version 2.4 August 1991"
  13.  
  14.  /* The following system defines should be defined with the -D
  15.     (for UNIX) or /DEFINE (for VMS) compiler options in the makefile,
  16.     not here.  They are shown here so you know what to define.
  17.  */
  18.  
  19. /*#define VMS*/  /* Set flag for VAX/VMS   system-dependent defns. */
  20. /*#define UNIX*/ /* Set flag for UNIX (ATT or BSD) defns. */
  21.  
  22. #ifdef VMS
  23.  /* If VMS system, define flag for extra VMS-isms in
  24.     iokeywds.h table unless NO_VMS_IO is defined. These
  25.     can be independently enabled by defining VMS_IO. */
  26. #ifndef NO_VMS_IO
  27. #define VMS_IO
  28. #endif /*NO_VMS_IO*/
  29.  /* Likewise define flag for VMS behavior in INCLUDE stmt
  30.     (defaulting extension, /NOLIST feature) unless
  31.     NO_VMS_INCLUDE is defined.  */
  32. #ifndef NO_VMS_INCLUDE
  33. #define VMS_INCLUDE
  34. #endif /*NO_VMS_INCLUDE*/
  35. #endif /*VMS*/
  36.  
  37.  /* set flag to allow options to start with '/' */
  38. #ifdef VMS
  39. #define OPTION_PREFIX_SLASH 1
  40. #endif
  41. #ifdef __TURBOC__
  42. #define OPTION_PREFIX_SLASH 1
  43. #endif
  44.  
  45.   /* The following defines cause Forchek to permit various
  46.      nonstandard things.  Purists can remove these defines
  47.      to disable them.
  48.      Disable all by defining STRICT_SYNTAX.
  49.   */
  50.  
  51. #ifndef STRICT_SYNTAX
  52. #define ALLOW_UNDERSCORES 1 /* Underscores in variable names */
  53. #ifdef VMS
  54. #define ALLOW_DOLLARSIGNS 1 /* VMS allows $ in identifiers too */
  55. #endif
  56. #define INLINE_COMMENT_CHAR '!' /* Inline comments starting with '!' */
  57. #define ALLOW_INCLUDE 1  /* The INCLUDE statement */
  58. #define ALLOW_DO_ENDO 1 /* The various DO loop extensions (including WHILE) */
  59. #endif
  60.  
  61.   /* Define to tolerate embedded blanks in numeric consts unless
  62.      feature turned off by defining NO_BLANKS_IN_NUMBERS. */
  63. #ifndef NO_BLANKS_IN_NUMBERS
  64. #define BLANKS_IN_NUMBERS
  65. #endif
  66.  
  67.   /* Define default source and output file extensions.  These
  68.    * can be overridden by defines on compiler commandline.
  69.    */
  70. #ifndef DEF_SRC_EXTENSION
  71. #ifdef VMS
  72. #define DEF_SRC_EXTENSION ".for"  /* VMS default extension */
  73. #endif
  74. #ifdef __TURBOC__
  75. #define DEF_SRC_EXTENSION ".for"  /* IBM PC default extension */
  76. #endif
  77. #endif /* DEF_SRC_EXTENSION */
  78.  
  79. #ifndef DEF_SRC_EXTENSION
  80. #define DEF_SRC_EXTENSION ".f"  /* Unix and all others */
  81. #endif
  82.   /* define default list-file extension */
  83. #ifndef DEF_LIST_EXTENSION
  84. #define DEF_LIST_EXTENSION ".lis"
  85. #endif
  86.   /* define default project-file extension */
  87. #ifndef DEF_PROJ_EXTENSION
  88. #define DEF_PROJ_EXTENSION ".prj"
  89. #endif
  90.   /* define project-file name for case of input from stdin */
  91. #ifndef STDIN_PROJ_FILENAME
  92. #define STDIN_PROJ_FILENAME "forchek.prj"
  93. #endif
  94.  
  95. #ifndef ENV_PREFIX
  96.   /* prefix for option environment variables */
  97. #define ENV_PREFIX "FORCHEK_"
  98. #endif
  99.  
  100. #ifndef MAXLINE
  101. #define MAXLINE 132 /* Maximum input line length.  Ignores past this. */
  102. #endif
  103. #ifndef MAXSTR
  104. #define MAXSTR 200 /* Longest string constant allowed */
  105. #endif
  106. #ifndef MAXIDSIZE
  107. #define MAXIDSIZE 31 /* Longest identifier allowed */
  108. #endif
  109.  
  110. #ifndef MAX_INCLUDE_DEPTH
  111. #define MAX_INCLUDE_DEPTH 16 /* Max nesting depth of include files */
  112. #endif
  113.  
  114. #define KEYHASHSZ 195 /* Size of keyword hashtable -- do not change */
  115. #define INTRINS_HASHSZ 261 /* Chosen to give few clashes -- change with care */
  116.  
  117. #ifdef SMALL_MACHINE  /* Use these for e.g. IBM PC */
  118. #ifndef HASHSZ   /* Hint: pick one with no square factors */
  119. #define HASHSZ 798     /* Size of symbol hashtable */
  120. #endif
  121. #ifndef STRSPACESZ
  122. #define STRSPACESZ 2000 /* Size of identifier string space */
  123. #endif
  124. #ifndef LOCSYMTABSZ
  125. #define LOCSYMTABSZ 200 /* Size of local symbol table */
  126. #endif
  127. #ifndef GLOBSYMTABSZ
  128. #define GLOBSYMTABSZ 200 /* Size of global symbol table */
  129. #endif
  130. #ifndef TOKENSPACESZ
  131. #define TOKENSPACESZ 200 /* Max number of tokens in token lists */
  132. #endif
  133.  
  134. #else  /* end if SMALL_MACHINE */
  135.  
  136. #ifdef LARGE_MACHINE  /* use these if space is no problem */
  137. #ifndef HASHSZ
  138. #define HASHSZ 20930     /* Size of symbol hashtable: must be <= max int */
  139. #endif
  140. #ifndef STRSPACESZ
  141. #define STRSPACESZ 40000 /* Size of identifier string space */
  142. #endif
  143. #ifndef LOCSYMTABSZ
  144. #define LOCSYMTABSZ 6000 /* Size of local symbol table */
  145. #endif
  146. #ifndef GLOBSYMTABSZ
  147. #define GLOBSYMTABSZ 4000 /* Size of global symbol table */
  148. #endif
  149. #ifndef TOKENSPACESZ
  150. #define TOKENSPACESZ 10000 /* Max number of tokens in token lists */
  151. #endif
  152.  
  153. #else  /* Defaults: Use these for average-size applications */
  154.  
  155. #ifndef HASHSZ
  156. #define HASHSZ 2002     /* Size of symbol hashtable: must be <= max int */
  157. #endif
  158. #ifndef STRSPACESZ
  159. #define STRSPACESZ 4000 /* Size of identifier string space */
  160. #endif
  161. #ifndef LOCSYMTABSZ
  162. #define LOCSYMTABSZ 600 /* Size of local symbol table */
  163. #endif
  164. #ifndef GLOBSYMTABSZ
  165. #define GLOBSYMTABSZ 400 /* Size of global symbol table */
  166. #endif
  167. #ifndef TOKENSPACESZ
  168. #define TOKENSPACESZ 1000 /* Max number of tokens in token lists */
  169. #endif
  170.  
  171. #endif /* end if LARGE_MACHINE else */
  172.  
  173. #endif/*end if SMALL_MACHINE else*/
  174.  
  175.  
  176. #define FALSE 0
  177. #define TRUE 1
  178.  
  179. #define NO_COL_NUM 999  /* impossible column number to suppress
  180.      * printing in error messages
  181.      */
  182.  
  183. /* Shared variable and function defns start here */
  184.  
  185. #ifdef MAIN
  186. #define SHARED  /* (nothing) */
  187. #else
  188. #define SHARED extern /* Non-main routines declare shared vars extern */
  189. #endif
  190.  
  191. #define PRIVATE static /* For non-shared functions */
  192.  
  193.  
  194. SHARED FILE
  195.             *input_fd,  /* Input file */
  196.             *list_fd, /* Output file for listing */
  197.      *project_fd;/* Project file for symtab info summary */
  198. SHARED char *current_filename, /* name of current input file */
  199.      *top_filename; /* name of toplevel parent input file */
  200. SHARED int incdepth;
  201.  
  202.  
  203. #ifdef MAIN
  204.   /* Options */
  205.   int
  206.     decls_required=FALSE, /* List all undeclared identifiers */
  207.     div_check = FALSE,  /* Check for possible division by zero */
  208.     ext_def_check = TRUE, /* Check defined status of externals*/
  209.     f77_standard=FALSE,  /* Warn of non-f77 constructs */
  210.     library_mode = FALSE, /* Set used-flag for all modules in file */
  211.     eol_is_space=TRUE,  /* Treat contd stmt linebreaks as space */
  212.     do_list = FALSE,  /* Listing-file flag */
  213.     port_check=FALSE,  /* Portability warnings */
  214.     make_project_file=FALSE, /* Save symtab defns in .prj file */
  215.     do_symtab = FALSE,  /* For symbol table printout */
  216.     sixclash = FALSE,  /* To check if names unique in 1st 6 chars */
  217.     verbose = TRUE,  /* Verbose output format */
  218.     print_version_num = FALSE, /* To print out the version number */
  219.     usage_check = TRUE,  /* Print set/used checks on variables */
  220.   /* Debugging flags */
  221.     debug_latest = FALSE, /* debug the latest addition */
  222.     show_resources = FALSE,
  223.     debug_parser = FALSE, /* grammar debug via DBG statements */
  224.     debug_lexer = FALSE,
  225.     debug_hashtab = FALSE,
  226.     debug_glob_symtab = FALSE,
  227.     debug_loc_symtab = FALSE;
  228. extern int yydebug;  /* grammar debug via yydebug */
  229.  
  230.   int  /* Settings */
  231.     comcheck_strictness = 3, /* 0 (no check) to 3 (exact type & size) */
  232.     max_stmt_col = 72,  /* End of statement field ( <= MAXLINE )*/
  233.     novice_level = 1;  /* 1 = green, 5 = wizard */
  234.  
  235.   /* StrSettings */
  236.   char
  237.     *out_fname=(char *)NULL; /* Output filename */
  238.  
  239. #else/* not ifdef MAIN */
  240.   SHARED int /* Options */
  241.     decls_required,
  242.     div_check, ext_def_check, f77_standard, library_mode,
  243.     eol_is_space, do_list, port_check,
  244.     make_project_file, do_symtab, sixclash, verbose,
  245.     print_version_num, usage_check,
  246.     debug_latest, show_resources, debug_parser, debug_lexer,
  247.     debug_hashtab, debug_glob_symtab, debug_loc_symtab;
  248.   SHARED int /* Settings */
  249.     comcheck_strictness,max_stmt_col,novice_level;
  250.   SHARED char /* StrSettings */
  251.     *out_fname;
  252. #endif
  253.  
  254. SHARED unsigned
  255.     line_num,  /* line num of current char */
  256.     col_num,  /* column num of current char */
  257.     next_line_num, /* line num of lookahead char */
  258.     next_col_num; /* column num of lookahead char */
  259.  
  260. SHARED unsigned
  261.     tab_count,  /* Count of tabs in noncomment lines exc in strings */
  262.     error_count, /* Count of syntax error messages per file */
  263.     warning_count; /* Count of warning messages per file */
  264.  
  265.   /* Resource usage information: */
  266. SHARED unsigned long
  267.     max_loc_symtab, /* amt of local symtab used */
  268.     max_glob_symtab, /* amt of global symtab used */
  269.     max_loc_strings, /* amt of local stringspace used */
  270.     max_glob_strings, /* amt of global stringspace used */
  271.     max_token_space; /* amt of token space used */
  272.  
  273. SHARED int
  274.     equivalence_flag,   /* true while parsing EQUIVALENCE statement */
  275.     initial_flag, /* true while only label or initial keywords read */
  276.     implicit_flag, /* true while parsing IMPLICIT statement */
  277.     implicit_letter_flag, /* true while getting letters in IMPLICIT list */
  278.     implicit_type_given,/* true if IMPLICIT type statement found */
  279.     implicit_none, /* true if IMPLICIT NONE statement found */
  280.     prev_token_class, /* token class of last-returned token */
  281.     curr_stmt_class; /* Token class of current stmt's leading token */
  282.  
  283.  
  284.  
  285.   /* Declare shared routines */
  286.  /* in advance.c */
  287. void init_scan(),finish_scan(),open_include_file();
  288. int flush_line_out();
  289.  
  290.  
  291.  /* in forchek.c */
  292. void print_a_line(), yyerror(), syntax_error(), msg_tail(),
  293.      warning(), nonstandard(), nonportable();
  294. char *add_ext(),*new_ext();
  295. int has_extension();
  296.  
  297.  /* in forlex.c */
  298. int yylex();
  299. void implied_id_token();
  300.  
  301.  /* in fortran.y/fortran.c */
  302. int yyparse();
  303. void init_parser();
  304.  
  305.  /* in intrinsics.c */
  306. unsigned long init_intrins_hashtab();
  307.  
  308.  /* in keywords.c */
  309. void init_keyhashtab();
  310.  
  311.  /* in prsymtab.c */
  312.  
  313. void check_arglists(),check_comlists();
  314.  
  315.  /* in symtab.c */
  316.  
  317. char *new_local_string(),*new_global_string();
  318. void init_globals(), init_symtab(), note_filename();
  319. char * token_name();
  320.  
  321.  
  322.  /* in symtab2.c */
  323. void    /* project file routines */
  324.  proj_file_out(),proj_file_in();
  325.